package gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.LayoutStyle.ComponentPlacement;

public class LoginPanel extends JPanel
{
    int blockType;
    public LoginPanel()
    {
        super();
        
        JLabel label = new JLabel("");
        label.setIcon(new ImageIcon(LoginPanel.class.getResource("/pics/Logo.png")));
        label.setFocusable(true);
        
        HintTextField hintTextFieldUsername = new HintTextField("Username");
        hintTextFieldUsername.setBackground(Color.LIGHT_GRAY);
        hintTextFieldUsername.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
        hintTextFieldUsername.setColumns(10);
        
        HintTextField hintTextFieldPass = new HintTextField("Password");
        hintTextFieldPass.setBackground(Color.LIGHT_GRAY);
        hintTextFieldPass.setFont(new Font("Comic Sans MS", Font.PLAIN, 11));
        hintTextFieldPass.setColumns(10);
        
        Icon buttonLogin = new ImageIcon("C:\\Users\\Teilmann\\Documents\\My Dropbox\\Ugamer\\pics\\LoginButton copy.png");
//        btnLogin.setOpaque(false);
        
        
        JRadioButton radioBtn = new JRadioButton("Remember Username");
        radioBtn.setForeground(Color.WHITE);
        radioBtn.setOpaque(false);
        
        final JButton button = new JButton("");
        button.setOpaque(false);
        button.setBorderPainted(false);
        button.setContentAreaFilled(false);
        button.addMouseMotionListener(new MouseMotionAdapter() {
        	
        	@Override
        	public void mouseMoved(MouseEvent arg0) {
				button.setIcon(new ImageIcon(LoginFrame.class.getResource("/pics/LoginButton_hover.png")));
			}
		});
        
        button.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				//LoginFrame.this.dispose();
			}
			@Override
			public void mouseExited(MouseEvent arg0) {
				button.setIcon(new ImageIcon(LoginFrame.class.getResource("/pics/LoginButton copy.png")));
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				//button.setIcon(new ImageIcon(LoginFrame.class.getResource("/pics/application_exit_pressed.png")));
			}
		});
        
        button.setIcon(new ImageIcon(LoginPanel.class.getResource("/pics/LoginButton copy.png")));
        GroupLayout groupLayout = new GroupLayout(this);
        groupLayout.setHorizontalGroup(
        	groupLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(groupLayout.createSequentialGroup()
        			.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(groupLayout.createSequentialGroup()
        					.addContainerGap()
        					.addComponent(label, GroupLayout.PREFERRED_SIZE, 214, GroupLayout.PREFERRED_SIZE))
        				.addGroup(groupLayout.createSequentialGroup()
        					.addGap(39)
        					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
        						.addComponent(hintTextFieldPass, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
        						.addComponent(hintTextFieldUsername, GroupLayout.PREFERRED_SIZE, 131, GroupLayout.PREFERRED_SIZE)
        						.addComponent(radioBtn)))
        				.addGroup(groupLayout.createSequentialGroup()
        					.addGap(49)
        					.addComponent(button)))
        			.addContainerGap(158, Short.MAX_VALUE))
        );
        groupLayout.setVerticalGroup(
        	groupLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(groupLayout.createSequentialGroup()
        			.addComponent(label)
        			.addGap(33)
        			.addComponent(hintTextFieldUsername, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(hintTextFieldPass, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addComponent(radioBtn)
        			.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        			.addComponent(button))
        );
        
        setOpaque(false);
        setLayout(groupLayout);
    }
    
    public void paintComponent(Graphics g)
    {
        super.paintComponent(g);
        Color ppColor = new Color(0, 0, 0, 170); //r,g,b,alpha
        g.setColor(ppColor);
        g.fillRect(0,0,260,500); //x,y,width,height
    }    
}